﻿<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<!DOCTYPE html>
<html>
<jsp:include page="../common/resource-head.jsp"/>
<body>
<jsp:include page="../common/common-top.jsp"/>
<div class="main-body">
  <div class="col-xs-6 col-xs-offset-3" style="padding-top: 20px">
    <div class="panel panel-primary">
      <div class="panel-heading">
        <h3 class="panel-title">更新信息</h3>
      </div>
      <div class="panel-body">
        <form class="form-horizontal" action="/admin/goods/update" method="post" enctype="multipart/form-data">
          <input type="hidden" name="id" value="${goods.id}">

          <div class="form-group">
            <label class="col-sm-3 control-label">名称</label>
            <div class="col-sm-8">
              <input class="form-control" name="name" value="${goods.name}">
            </div>
          </div>

          <div class="form-group">
            <label class="col-sm-3 control-label">分类</label>
            <div class="col-sm-8">
              <select class="form-control double" name="category">
                <c:forEach items="${CATEGORY_LIST}" var="item">
                  <option
                      <c:if test="${goods.category == item}">selected</c:if>  >${item}
                  </option>
                </c:forEach>

              </select>
            </div>
          </div>


          <div class="form-group">
            <label class="col-sm-3 control-label">作家</label>
            <div class="col-sm-8">
              <input class="form-control" name="author" value="${goods.author}">
            </div>
          </div>

          <div class="form-group">
            <label class="col-sm-3 control-label">标签</label>
            <div class="col-sm-8">
              <input class="form-control" name="tag" value="${goods.tag}">
            </div>
          </div>


          <div class="form-group">
            <label class="col-sm-3 control-label">价钱</label>
            <div class="col-sm-8">
              <input class="form-control" name="money" value="${goods.money}">
            </div>
          </div>


          <div class="form-group">
            <label class="col-sm-3 control-label">状态</label>
            <div class="col-sm-8">
              <select class="form-control double" name="status">
                <option
                    <c:if test="${goods.status == '上架'}">selected</c:if>  >上架
                </option>
                <option
                    <c:if test="${goods.status == '下架'}">selected</c:if>  >下架
                </option>
              </select>
            </div>
          </div>

          <div class="form-group">
            <label class="col-sm-3 control-label">库存</label>
            <div class="col-sm-8">
              <input class="form-control double" type="number" name="count" value="${goods.count}">
            </div>
          </div>

          <div class="form-group">
            <label class="col-sm-3 control-label">简介</label>
            <div class="col-sm-8">
              <textarea name="remark" class="form-control">${goods.remark}</textarea>
            </div>
          </div>


          <div class="form-group">
            <label class="col-sm-3 control-label">展示图</label>
            <div class="col-sm-8">
              <input class="form-control" name="file" id="path" type="file">
            </div>
          </div>


          <div class="form-group">
            <div id="md-content" style="z-index: 1 !important;">
              <script id="container" name="content" type="text/plain">${goods.content}</script>
            </div>
          </div>
          <div class="form-group">
            <div class="col-sm-offset-4 col-sm-3">
              <button type="submit" class="btn btn-primary">提交</button>
            </div>
          </div>
        </form>
      </div>
    </div>
  </div>
</div>

</body>
<jsp:include page="../common/resource-script.jsp"/>
<script>
  uploadFile("path", "${goods.path}");
</script>
<script type="text/javascript" src="/webjars/ueditor-bower/1.4.3/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="/webjars/ueditor-bower/1.4.3/ueditor.all.js"></script>
<!-- 实例化编辑器 -->
<script type="text/javascript">
  var ue = UE.getEditor('container', {
    autoHeightEnabled: true,
    // 服务器统一请求接口路径
    serverUrl: "/ueditor/server"
  });

  function formSubmit() {
    $("#content").val(ue.getContent());
  }
</script>
</html>

